(function() {
	document.addEventListener('DOMContentLoaded', function() {
		var html = document.documentElement;
		var windowWidth = html.clientWidth;
		html.style.fontSize = windowWidth / 7.5 + 'px';
	}, false);
})();
//fastclick
//$.mobile.buttonMarkup.hoverDelay = 0;
$(document).bind("mobileinit", function() {
	$.mobile.allowCrossDomainPages = true;
});
window.addEventListener('onload', function() {
	FastClick.attach(document.body);
}, false);

//手机端判断各个平台浏览器及操作系统平台
function checkPlatform(){
	if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)){
		$('.fanhuibtn').hide();
		$('.data-time').removeClass('fr');
		$('.mui-content').addClass('active');
		$('.list-content').removeClass('paddingtop80');
	}
}
//加载框
//扩展mui.showLoading
(function($, window) {
    //显示加载框
    $.showLoading = function(message,type) {
        if ($.os.plus && type !== 'div') {
            $.plusReady(function() {
                plus.nativeUI.showWaiting(message);
            });
        } else {
            var html = '';
            html += '<i class="mui-spinner mui-spinner-white"></i>';
            html += '<p class="text">' + (message || "数据加载中") + '</p>';

            //遮罩层
            var mask=document.getElementsByClassName("mui-show-loading-mask");
            if(mask.length==0){
                mask = document.createElement('div');
                mask.classList.add("mui-show-loading-mask");
                document.body.appendChild(mask);
                mask.addEventListener("touchmove", function(e){e.stopPropagation();e.preventDefault();});
            }else{
                mask[0].classList.remove("mui-show-loading-mask-hidden");
            }
            //加载框
            var toast=document.getElementsByClassName("mui-show-loading");
            if(toast.length==0){
                toast = document.createElement('div');
                toast.classList.add("mui-show-loading");
                toast.classList.add('loading-visible');
                document.body.appendChild(toast);
                toast.innerHTML = html;
                toast.addEventListener("touchmove", function(e){e.stopPropagation();e.preventDefault();});
            }else{
                toast[0].innerHTML = html;
                toast[0].classList.add("loading-visible");
            }
        }   
    };

    //隐藏加载框
      $.hideLoading = function(callback) {
        if ($.os.plus) {
            $.plusReady(function() {
                plus.nativeUI.closeWaiting();
            });
        } 
        var mask=document.getElementsByClassName("mui-show-loading-mask");
        var toast=document.getElementsByClassName("mui-show-loading");
        if(mask.length>0){
            mask[0].classList.add("mui-show-loading-mask-hidden");
        }
        if(toast.length>0){
            toast[0].classList.remove("loading-visible");
            callback && callback();
        }
      }
})(mui, window);

function jsonpDataInit(data) {
    if(data.Message){
        alert(data.Message);
        return;
    }
    if(data.rows==""){
        var rows ={"row":[]};
        data.rows=rows;
    }else if(!data.rows.row.length){
        var row = [data.rows.row];
        data.rows.row=row;
    }
    if(Object.prototype.toString.call( data.title.column) !='[object Array]' ){
        data.title.column = [data.title.column];
    }
    for(var i=0;i<data.rows.row.length;i++){
        if(Object.prototype.toString.call(data.rows.row[i].cell) !='[object Array]' ){
            data.rows.row[i].cell = [data.rows.row[i].cell];
        }
        for(var j=0;j<data.rows.row[i].cell.length;j++){
            if(Object.prototype.toString.call(data.rows.row[i].cell[j])=='[object Object]'){
                data.rows.row[i].cell[j] = data.rows.row[i].cell[j]['#text'];
            }
            if(data.rows.row[i].cell[j].indexOf("未知[")>-1&&data.rows.row[i].cell[j].indexOf("]")>-1){
                data.rows.row.splice(i,1);
                i--;
                break;
            }
        }
    }
    return data;
}